<?php

require_once 'views/helpers/Route.php';

class Zend_View_Helper_Button extends Zend_View_Helper_Route
{
    public function button($caption, $route = null, $class="button_large")
    {   
        $action = 'alert("Button has no action")';
        
        if ($route) {
            
            if(!isset($route['controller'])) {
                $route['controller'] = null;
            }
            
            if(!isset($route['action'])) {
                $route['action'] = null;
            }
            
            if(!isset($route['params'])) {
                $route['params'] = array();
            }
            
            $url = $this->route($route['controller'], $route['action'], $route['params']);
            $action = 'window.location=\''.$url.'\'';
        }
        
        return '<div class="'.$class.'" onclick="'. $action . '">' . $caption . "</div>";
    }
}